function flushCode(object)
{
    // document.getElementById("code").src = "/code?date=" + new Date();
    // object.src="/code?date=" + new Date();
    $(object).attr("src", "http://localhost:8080/code?date=" + new Date());
}

function login()
{
    let username = $("#username").val();
    let password = $("#password").val();
    let code = $("#code").val();
    let reg = /^[a-zA-Z]\w{5,15}$/;
    if (!reg.test(username))
    {
        alert("你输入用户名的格式不正确!");
        return;
    }
    if (!reg.test(password))
    {
        alert("你输入密码的格式不正确!");
        return;
    }
    console.log({username: username, password: password, code: code});
    let data = fontAjax('/login', {username: username, password: password, code: code}, 'post');

    console.log(data);
    if (data.result == 1)
    {
        sessionStorage.setItem("loginUsername", username);
        window.location.href = "/back/manage.html";
    }
    else if (data.result == 0)
    {
        alert("你输入的用户名或者密码不正确");
    }
    else if (data.result == -1)
    {
        alert("验证码输入不正确");
    }
}